<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<%@include file="../../common/include-header.jsp" %>

<body class="gray-bg">

<div class="container-div">
    <div class="row">
        <div class="col-sm-12 search-collapse">
            <form id="role-form">
                <div class="select-list">
                    <ul>
                        <li>
                            用户类型：
                            <select name="userType">
                                <option value="1" selected>教师</option>
                                <option value="2">学生</option>
                            </select>
                        </li>
                        <li>
                            用户名称：<input type="text" name="userName"/>
                        </li>
                        <li>
                            <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i
                                    class="fa fa-search"></i>&nbsp;搜索</a>
                            <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i
                                    class="fa fa-refresh"></i>&nbsp;重置</a>
                        </li>
                    </ul>
                </div>
            </form>
        </div>

        <div class="col-sm-12 select-table table-striped">
            <table id="bootstrap-table" data-mobile-responsive="true"></table>
        </div>
    </div>
</div>
<%@include file="../../common/include-footer.jsp" %>
<script th:inline="javascript">
    var prefix = "/admin";
    $(function () {
        var options = {
            url: prefix + "/list",
            createUrl: prefix + "/add",
            updateUrl: prefix + "/update/{id}",
            removeUrl: prefix,
            sortName: "",
            height: 500,
            modalName: "用户",
            columns: [
                {
                    field: 'id',
                    title: '用户编号'
                },
                {
                    field: 'name',
                    title: '姓名',
                    sortable: true
                },
                {
                    field: 'phone',
                    title: '电话',
                    sortable: true
                },
                {
                    field: "email",
                    title: '邮件',
                    align: 'center',
                },
                {
                    field: "lastLoginTime",
                    title: '最后登入时间',
                    align: 'center',
                    formatter: function (val, item, rowIndex) {
                        var dateee = new Date(val).toJSON();
                        var date = new Date(+new Date(dateee) + 16 * 3600 * 1000).toISOString().replace(/T/g, ' ').replace(/\.[\d]{3}Z/, '');
                        return date;
                    }
                },
                {
                    field: 'identityId',
                    title: '用户类型',
                    formatter: function (value, item, index) {
                        if (item.identityId == '10001') {
                            return '<span class="label label-success">教师</span>';
                        } else if (item.identityId == '10000') {
                            return '<span class="label label-primary">学生</span>';
                        }
                    }
                }
                ]
        };
        $.table.init(options);
    });
</script>
</body>
</html>
